define(['knockout', 'store', 'util'], function (ko, Store, Util) {
    function ViewModel(params) {
        Util.extend(this, params);

        var scope = this;
        var listStore = new Store({
            model: scope.params.list.model,
            pageSize: 0
        });
        var shuttleStore = new Store({
            model: scope.params.shuttle.model,
            autoLoad: false,
            pageSize: 0
        });

        scope._style = {height: '18rem'};

        if (scope.params.height) scope._style.height = Util.calculateSize(scope.params.height);

        scope.list = {
            showOperation: false,
            displayField: scope.params.list.displayName,
            store: listStore,
            onItemSelected: function (item) {
                shuttleStore.setProxy({url: shuttleStore.getProxy().originalUrl.formatTpl(item.id())});
                shuttleStore.load();
            },
            onNoneItemSelected: function () {
                shuttleStore.setProxy({url: ''});
                shuttleStore.empty();
            }
        };
        scope.shuttle = {
            params: $.extend({
                    store: shuttleStore,
                    _items: scope.params._items
                },
                scope.params.shuttle)
        };
    }


    return ViewModel;
});
